#include <unistd.h>
#include<stdio.h>
#include<stdlib.h>
#include <sys/wait.h>
#include <sys/types.h>
bool vis[301][301];
int main() 
{
  printf("pid:%d ppid%d\n",getpid(),getppid());
  sleep(2);
  pid_t pid=fork();
  if(pid==0)
  {
    int cnt=5;
    while(cnt--)
    {
      printf("I'm kid pid:%d ppid%d\n",getpid(),getppid());  
      sleep(1);
    } 
   exit(1);//退出码为1
  }
  sleep(10);
  int status=0;
  pid_t w=waitpid(pid,&status,0);
  if(w>0)
  {
    printf("wait id:%d wait status%d exit signl:%d exit code:%d\n",w,status,status&0x7f,((status>>8)&0xff));//对状态码进行位运算取得退出信号和退出id 状态码32位前16位是退出状态 后16位是终止信号
        
 }
  return 0;
}
